# options
options(scipen = 999)
"%ni%" = Negate("%in%")
# library
library(cryptor)
library(data.table)
library(plotly)
library(lubridate)
library(h2o)
range01 <- function(x){(x-min(x))/(max(x)-min(x))}
# predict_days
predict_days = 8
# BTC_INC
tmp = get_historical_price(fsym="BTC", tsym="KRW", end_time=Sys.Date(), unit='hour',limit=1000)
tmp = as.data.table(tmp)
tmp = tmp[time>'2019-03-31',]
BTC_INC = tmp
BTC_INC = BTC_INC[,list(time,BTC=range01(close)*100)]
# BCH_INC
tmp = get_historical_price(fsym="BCH", tsym="KRW", end_time=Sys.Date(), unit='hour',limit=1000)
tmp = as.data.table(tmp)
tmp = tmp[time>'2019-03-31',]
BCH_INC = tmp
BCH_INC = BCH_INC[,list(time,BCH=range01(close)*100)]
# ETH_INC
tmp = get_historical_price(fsym="ETH", tsym="KRW", end_time=Sys.Date(), unit='hour',limit=1000)
tmp = as.data.table(tmp)
tmp = tmp[time>'2019-03-31',]
ETH_INC = tmp
ETH_INC = ETH_INC[,list(time,ETH=range01(close)*100)]
# XRP_INC
tmp = get_historical_price(fsym="XRP", tsym="KRW", end_time=Sys.Date(), unit='hour',limit=1000)
tmp = as.data.table(tmp)
tmp = tmp[time>'2019-03-31',]
XRP_INC = tmp
XRP_INC = XRP_INC[,list(time,XRP=range01(close)*100)]
# REP_INC
tmp = get_historical_price(fsym="REP", tsym="KRW", end_time=Sys.Date(), unit='hour',limit=1000)
tmp = as.data.table(tmp)
tmp = tmp[time>'2019-03-31',]
REP_INC = tmp
REP_INC = REP_INC[,list(time,REP=range01(close)*100)]
# plot
plot_ly() %>%
add_trace(data=BTC_INC, x=~time, y=~BTC, type = 'scatter', mode = 'lines+markers', line = list(width = 1), name="비트코인") %>%
add_trace(data=BCH_INC, x=~time, y=~BCH, type = 'scatter', mode = 'lines+markers', line = list(width = 1), name="비트코인캐시") %>%
add_trace(data=ETH_INC, x=~time, y=~ETH, type = 'scatter', mode = 'lines+markers', line = list(width = 1), name="이더리움") %>%
add_trace(data=XRP_INC, x=~time, y=~XRP, type = 'scatter', mode = 'lines+markers', line = list(width = 1), name="리플") %>%
add_trace(data=REP_INC, x=~time, y=~REP, type = 'scatter', mode = 'lines+markers', line = list(width = 1), name="어거") %>%
layout(xaxis=list(fixedrange=T, title="date"),yaxis=list(fixedrange=T, title="price"),autosize = F, width = 900) %>%
config(displayModeBar = F)
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()